/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author Alberto, Alessandra
 */
@Entity
@NamedQuery(
            name = "findOneDayNotificationsByEvent",
            query = "SELECT odn FROM OneDayNotification odn WHERE odn.event = :ODNevent"
)
public class OneDayNotification extends Notification implements Serializable {
    
    private static final long serialVersionUID = 1L;
    
    @ManyToOne
    @JoinColumn(name = "idevent", referencedColumnName = "id")
    private OutdoorEvent event;

    public OutdoorEvent getEvent() {
        return event;
    }

    public void setEvent(OutdoorEvent event) {
        this.event = event;
    }
    
    public OneDayNotification () {
        
    }

    public OneDayNotification(OutdoorEvent event, User user) {
        super(user);
        this.event = event;
    }
    
    @Override
    public String toString() {
        return "The event " + event.getName() + " has a bad weather forecast: " + event.getWeatherforecast().getName();
    }
   
}
